package com.example.xd.gamedemo.pingtu;

import android.graphics.Bitmap;

import java.util.ArrayList;
import java.util.List;

/**
 * @auther XuDan on 2020/4/15.
 */
public class ClipBitmepUtil {
    public static List<ImageInfo> getImgs(Bitmap bitmap, int colum) {
        ArrayList<ImageInfo> imageInfos = new ArrayList<>();
        int index = 0;
        int height = bitmap.getHeight();
        int width = bitmap.getWidth();
        int min_len = Math.min(width, height);
        int bmp_len = min_len / colum;
        for (int i = 0; i < colum; i++) {
            for (int j = 0; j < colum; j++) {
                Bitmap clip_bmp = Bitmap.createBitmap(bitmap, i * bmp_len, j * bmp_len, bmp_len, bmp_len);
                ImageInfo imageInfo = new ImageInfo(index, clip_bmp,bmp_len);
                imageInfos.add(imageInfo);
                index++;
            }
        }
        return imageInfos;
    }
}
